package com.TTBook.common.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class SystemConfig {
	
	private SystemConfig(){};
	
	public static Properties getResourceAsPropertiesByFile(String resources)throws IOException
	{
		Properties prop = new Properties();
		InputStream  in=null;
		try{
		
		File propFile = new File(resources);
		if(!propFile.exists())
		{
			throw new IOException("Can not find resources"+resources);
		}
		in = new FileInputStream(propFile);
		prop.load(in);
		
		}finally{
			if(in != null)
			{
				in.close();
			}
		}
		return prop;
	}
   public static void main(String[] args)throws Exception
   {
	   String resources = "D:\\appConfigFile.properties";
	   Properties prop = SystemConfig.getResourceAsPropertiesByFile(resources);
	   String mallUrl = new String(prop.getProperty("MallUrl").getBytes("ISO-8859-1"),"UTF-8");
	   String mallTitle = new String(prop.getProperty("MallTitle").getBytes("ISO-8859-1"),"UTF-8");;
	   System.out.println("MallUrl = "+mallUrl+"\n"+"MallTitle = "+mallTitle);
   }
}
